import http from './http'

export interface DashboardStat {
  title: string
  value: number
  suffix: string
  color: string
  type: string
  gradient: string
  trend: number
}

export interface RecentAlert {
  title: string
  severity: string
  time: string
}

export interface ServiceStatus {
  name: string
  status: string
  responseTime: number
}

export interface PerformanceMetric {
  name: string
  value: number
  unit: string
  percent: number
}

/**
 * 获取Dashboard概览数据
 */
export const getDashboardOverview = async () => {
  return await http.get<{ stats: DashboardStat[] }>('/dashboard/overview')
}

/**
 * 获取最近告警
 */
export const getRecentAlerts = async (limit: number = 5) => {
  return await http.get<RecentAlert[]>('/dashboard/recent-alerts', { params: { limit } })
}

/**
 * 获取服务状态
 */
export const getServicesStatus = async () => {
  return await http.get<ServiceStatus[]>('/dashboard/services')
}

/**
 * Get performance metrics
 */
export const getPerformanceMetrics = async (hours: number = 24) => {
  return await http.get<any>('/dashboard/performance', { params: { hours } })
}
